package com.qipay.baas.mapper;

import com.qipay.baas.model.CardBind;
import com.qipay.baas.model.CardBindExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CardBindMapper {
    @SelectProvider(type=CardBindSqlProvider.class, method="countByExample")
    int countByExample(CardBindExample example);

    @Delete({
        "delete from `card_bind`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into `card_bind` (`id`, `user_id`, ",
        "`bank`, `sub_bank`, `card`, ",
        "`name`, `mobile`)",
        "values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, ",
        "#{bank,jdbcType=VARCHAR}, #{subBank,jdbcType=VARCHAR}, #{card,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR})"
    })
    int insert(CardBind record);

    @InsertProvider(type=CardBindSqlProvider.class, method="insertSelective")
    int insertSelective(CardBind record);

    @SelectProvider(type=CardBindSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="bank", property="bank", jdbcType=JdbcType.VARCHAR),
        @Result(column="sub_bank", property="subBank", jdbcType=JdbcType.VARCHAR),
        @Result(column="card", property="card", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR)
    })
    List<CardBind> selectByExample(CardBindExample example);

    @Select({
        "select",
        "`id`, `user_id`, `bank`, `sub_bank`, `card`, `name`, `mobile`",
        "from `card_bind`",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="bank", property="bank", jdbcType=JdbcType.VARCHAR),
        @Result(column="sub_bank", property="subBank", jdbcType=JdbcType.VARCHAR),
        @Result(column="card", property="card", jdbcType=JdbcType.VARCHAR),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="mobile", property="mobile", jdbcType=JdbcType.VARCHAR)
    })
    CardBind selectByPrimaryKey(Long id);

    @UpdateProvider(type=CardBindSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(CardBind record);

    @Update({
        "update `card_bind`",
        "set `user_id` = #{userId,jdbcType=BIGINT},",
          "`bank` = #{bank,jdbcType=VARCHAR},",
          "`sub_bank` = #{subBank,jdbcType=VARCHAR},",
          "`card` = #{card,jdbcType=VARCHAR},",
          "`name` = #{name,jdbcType=VARCHAR},",
          "`mobile` = #{mobile,jdbcType=VARCHAR}",
        "where `id` = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CardBind record);
}